<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:w="http://www.apusic.com/jsf/widget" xmlns:layout="http://www.apusic.com/jsf/layout"
	xmlns:ajax="http://www.apusic.com/jsf/ajax" renderKitId="AJAX"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:om="http://www.apusic.com/jsf/misc">
	<w:head>
		<om:elite>
			<![CDATA[
					define beanClass = param.beanClass;
					define beanId = param.beanId;
					define attachmentType = param.attachmentType;
					define height = param.height;
			]]>
		</om:elite>
		<w:script src="/javascript/k4.js" type="text/javascript" language="UTF-8"></w:script>
		<script type="text/javascript">
		//<![CDATA[
			function showUpload(){
				fileUpload.url='#{facesContext.externalContext.requestContextPath}/uploadAttachment?beanClass=#{beanClass}&beanId=#{beanId}&attachmentType=#{attachmentType}';
				fileUpload.show();
			}
			function downloadAttach(){
				var sid = attachmentComponent.getSelectionModel().getSelected().get('id');
				window.location.href='#{facesContext.externalContext.requestContextPath}/downloadAttachment?id='+sid;
			}
			function deleteAttach(){
				if(attachmentComponent.getSelections().length == 0){
					alert("请选择一条记录！");
					return false;
				}
				return confirm('你确定要删除吗？');
			}
			function formatFloat(src, pos){
    			return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
    		}
			function transLength(v, m , r, rIndex){
				if(1024*1024*10>v)
					return formatFloat(v/1024,2)+'KB';
				return formatFloat(v/1024/1024,2)+'MB';
			}
			function reloadAttach(){
				var store=attachmentComponent.getStore();
				store.reload(store.lastOptions);
			}
			function closeWindow(){
				fileUpload.hide();
				reloadAttach();
			}
			
			function imageFormat(v){
			  if('doc'==v||'docx'==v){
			    return '<img src="#{facesContext.externalContext.requestContextPath}/images/word.gif"/>';
			  }else if('ppt'==v){
			    return '<img src="#{facesContext.externalContext.requestContextPath}/images/ppt.gif"/>';
			  }else if('zip'==v){
			    return '<img src="#{facesContext.externalContext.requestContextPath}/images/zip.gif"/>';
			  }else if('excel'==v){
			    return '<img src="#{facesContext.externalContext.requestContextPath}/images/excel.gif"/>';
			  }else{
			    return '';
			  }
			 }
			 
			 function levelFormatter(v){
			   if(v==null||v=='null'){
			     return '';
			   }
			   return v;
			 }
			 
			 function openFlow(v, m , r, rIndex){
			   var dirId = r.get('id');
			   return "<a href='javascript:showImage(\""+dirId+"\")'>查看</a>";
			 }
			 
			 function showImage(id){
			   var url='#{facesContext.externalContext.requestContextPath}/modules/process/design/process-img.jsp?beanId='+id;
		       showRelation('查看流程图',url);
			 }
			 function exeProcess(url){
			   showRelation('执行流程',url);
			 }
			 
			 
			function showRelation(title,url){
			   iframe_rd1.location.href=url;
			   window_rd1.setTitle(title);
			   window_rd1.show();
		    }
		    function closeWindow(jsvar){
			   window_rd1.hide();
			   refreshData(jsvar);
		    }
		        
            function refreshData(){
			   window_rd1.hide();
			   window.location.reload();
		    }
		//]]>
		</script>
	</w:head>
	<w:page title="流程">
		<layout:borderLayout fitToBody="true" border="false">
			<layout:panel region="north" height="26" width="100%">
				<w:form groupId="group1">
					<w:toolBar>
						<w:button value="新建流程" id="addProcess" alwaysSubmit="false"
							onclick="javascript:addCenterLayoutTab('drawImage','绘制流程图','#{facesContext.externalContext.requestContextPath}/modules/process/design/drawProcess.jsp?beanId=#{beanId}');" />
						<w:separator />
						<w:button value="编辑流程" id="editProcess"></w:button>
						<w:separator />
						<w:button value="删除流程" id="delProcess" onclick="return deleteAttach();" />
						<w:separator />
						<w:button value="执行流程" id="executeProcess"/>
					</w:toolBar>
				</w:form>
			</layout:panel>
			<layout:panel region="center" border="false" autoScroll="true">
				<w:dataGrid border="false" id="attachmentsList" paged="true" showRowNumber="true"
					jsvar="attachmentComponent" selectionModel="#{selectionModel.checkbox}" singleSelect="true"
					autoExpandColumn="2" autoHeight="true" toolBarPosition="bottom">
					<w:outputColumn header="ID" id="id" hidden="true"></w:outputColumn>
					<w:outputColumn header="文件名" id="fileName" width="120" wrap="true"></w:outputColumn>
					<w:outputColumn header="流程级别" id="level" width="80" clientFormatter="levelFormatter"></w:outputColumn>
					<w:outputColumn header="长度" id="length" width="100" clientFormatter="transLength"></w:outputColumn>
					<w:outputColumn header="创建时间" id="createTime" width="85" converter="dateFormatter"></w:outputColumn>
					<!--<w:outputColumn id="operation" header="操作" width="100" clientFormatter="openFlow"></w:outputColumn>
					--><w:pagingToolbar displayInfo="true" displayMsg="显示 {0} - {1}，共 {2} 条" />
				</w:dataGrid>
			</layout:panel>
		</layout:borderLayout>

		<layout:window jsvar="window_rd1" modal="true" show="false" autoScroll="true" width="720"
			height="380">
			<w:iframe id="iframe_rd1" name="iframe_rd1" style="width:100%;height:99%;" frameborder="0"></w:iframe>
		</layout:window>
	</w:page>
	<script type="text/javascript">
		//<![CDATA[
		Ext.onReady(function (){
			//fileUpload.height=#{height};
			//fileUpload.width=450;
		});
		//]]>
	</script>
</f:view>
